package com.sophialex.health.record.common.util;

import com.sophialex.health.common.platform.SuperContext;
import com.sophialex.health.system.frame.util.RationalDrugUseReadDll;

public class ZyfyContants {
	public static String FFYTY = "0"; // 发药退药是不是一起显示 0不显示1显示
	public static String FMODE = "1"; // 住院发药查询是按科室还是申请科室查询:0科室,1申请科室
	public static String FQYSJ = "0"; // 住院发药是否启用时间设置;0不启用,1启用;
	public static String ZYFYDYYL = "1";// 1为不预览,0为预览
	public static String ZYFYBRINFO = "0";// 0为不打印基本信息,1为打印基本信息
	public static boolean ZYFYDYHFY = false; // 住院发药先打印后发药

	public static boolean abHisEnabled = false; // 是否启用合理用药
	public static boolean FPassEnabled = false; // 标识合理用药是否初始化成功

	public static String ZyFYISPRINT = "0";// 住院发药打印,1为打印,0为不打印
	public static String ZyPRINTPROMPT = "0";// 住院发药打印提示窗口,1为打开,0为不打开

	public static void initFySetting() {
		if (ParamUtil.getParamValue(ParamUtil.FFYTYSTATE) != null) {
			FFYTY = ParamUtil.getParamValue(ParamUtil.FFYTYSTATE).toString();
		}

		if (ParamUtil.getParamValue(ParamUtil.ZYSQMODE) != null) {
			FMODE = ParamUtil.getParamValue(ParamUtil.ZYSQMODE).toString();
		}

		if (ParamUtil.getParamValue(ParamUtil.ISQYSJ) != null) {
			FQYSJ = ParamUtil.getParamValue(ParamUtil.ISQYSJ).toString();
		}

		if (ParamUtil.getParamValue(ParamUtil.ZYFYDYYL) != null) {
			if ("1".equals(ParamUtil.getParamValue(ParamUtil.ZYFYDYYL))) {
				ZYFYDYYL = "0";
			}
		}
		if (ParamUtil.getParamValue(ParamUtil.ZYFYBRINFO) != null) {
			if ("1".equals(ParamUtil.getParamValue(ParamUtil.ZYFYBRINFO))) {
				ZYFYBRINFO = "1";
			}
		}
		if (ParamUtil.getParamValue(ParamUtil.DYHFY) != null) {
			if ("1".equals(ParamUtil.getParamValue(ParamUtil.DYHFY))) {
				ZYFYDYHFY = true;
			}
		}

		if (ParamUtil.getParamValue(ParamUtil.ISQYHLYY) != null) {
			if ("1".equals(ParamUtil.getParamValue(ParamUtil.ISQYHLYY))) {
				abHisEnabled = true;
				initHlyy();
			}
		}

		// if (ParamUtil.getParamValue(ParamUtil.ZyFYISPRINT) != null) {
		if (!"0".equals(ParamUtil.getParamValue(ParamUtil.ZyFYISPRINT))) {
			ZyFYISPRINT = "1";
		}
		// }

		if (ParamUtil.getParamValue(ParamUtil.ZyPRINTPROMPT) != null) {
			if ("1".equals(ParamUtil.getParamValue(ParamUtil.ZyPRINTPROMPT))) {
				ZyPRINTPROMPT = "1";
			}
		}
	}

	public static Long KSHZFY = 11L; // 科室汇总发药
	public static Long ZYABRFY = 12L;// 住院按病人发药
	public static Long ZDBRFY = 13L;// 指定病人发药
	public static Long CYDYFY = 14L;// 出院带药发药
	public static Long DSYFY = 15L;// 大输液发药
	public static Long JSMZFY = 16L;// 精神麻醉发药
	public static Long BQHZFY = 19L;//病区汇总发药
	public static Long BRDSY = 17L;//大输液查询(按病人发药)
	public static Long KSHZTY = 21L;// 科室汇总退药
	public static Long ZYABRTY = 22L;// 住院按病人退药
	public static Long ZDBRTY = 23L;// 指定病人退药
	public static Long CYDYTY = 24L;// 出院带药退药
	public static Long DSYTY = 25L;// 大输液退药
	public static Long JSMZTY = 26L;// 精神麻醉退药
	public static Long BQHZTY = 29L;//病区汇总发药

	public static int FY_TYPE = 1;// 发药
	public static int TY_TYPE = 2;// 退药

	public static String KSHZFYTY = "KSHZFYTY"; // 科室汇总发药
	public static String ZYABRFYTY = "ZYABRFYTY";// 住院按病人发药
	public static String ZDBRFYTY = "ZDBRFYTY";// 指定病人发药
	public static String CYDYFYTY = "CYDYFYTY";// 出院带药发药
	public static String DSYFYTY = "DSYFYTY";// 大输液发药
	public static String JSMZFYTY = "JSMZFYTY";// 精神麻醉发药

	public static void initHlyy() {
		// File lmyInifile;
		String lcExePath = "";
		String lcIniValue = "1";
		String lcUserCode = ""; // 统一编号
		String lcUserName = ""; // 用户姓名
		String lcDeptCode = ""; // 科号
		String lcDeptName = ""; // 科室

		if (("100".equals(lcIniValue))
				|| (("1".equals(lcIniValue)) && (abHisEnabled == true))) {
			if (RationalDrugUseReadDll.LoadPassShareDll()) {
				RationalDrugUseReadDll.PassRegisterServer();
			}
			if (RationalDrugUseReadDll.LoadPassDll()) {
//				lcUserCode = SuperContext.getCurrentUser().getFtybh();
//				lcUserName = SuperContext.getCurrentUser().getFname();
//				lcDeptCode = SuperContext.getCurrentUser().getFkh();
//				lcDeptName = SuperContext.getCurrentUser().getFks();
				try {
					if (RationalDrugUseReadDll.PassInit(lcUserCode + "/"
							+ lcUserName, lcDeptCode + "/" + lcDeptName,
							new Integer(10)) == 1) {
						FPassEnabled = true;
						RationalDrugUseReadDll.PassSetControlParam(new Integer(
								1), new Integer(2), new Integer(0),
								new Integer(2), new Integer(1));
					} else {
						FPassEnabled = false;
					}
				} catch (Exception e) {
					FPassEnabled = false;
				}
			}
		} else {
			FPassEnabled = false;
		}
	}
}
